/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rie06.openvoip.client.IHM.home;

import com.rie06.openvoip.client.IHM.communication.CommunicationController;
import com.rie06.openvoip.client.IHM.home.ListContactPanel;
import com.rie06.openvoip.client.Contact;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.*;
import org.apache.log4j.Logger;

/**
 * @author sylvain
 */
public class PanelContact extends JPanel {
    
    private Contact contact;
    private JLabel labelDescription;
    private JLabel labelIpAdress;
    private JButton buttonStart;
    private JButton buttonDelete;
    private ListContactPanel listContactPanel;
    private CommunicationController communicationController;
    private JScrollPane scrollPane;
    private Color color = Color.orange;
    private JLabel labelOnline;
    private JLabel labelOffline;
    private static final Logger logger = Logger.getLogger(PanelContact.class);
    
    public PanelContact(ListContactPanel listContactPanel, Contact contact, CommunicationController communicationController) {
        
        this.contact = contact;
        this.communicationController = communicationController;
        this.listContactPanel = listContactPanel;
        this.setPreferredSize(new Dimension(180, 50));     
        
        scrollPane = new JScrollPane(this);

        labelDescription = new JLabel(contact.getName());
        
        Icon iconStart = new ImageIcon("images/Dial16.png"); 
        buttonStart = new JButton(iconStart);
        
        Icon iconDelete = new ImageIcon("images/delete16.png"); 
        buttonDelete = new JButton(iconDelete);
        
        Icon iconOnline = new ImageIcon("images/pastilleGreen.jpg");
        Icon iconOffline = new ImageIcon("images/pastilleRed.jpg");
        
        labelOnline = new JLabel(iconOnline);
        labelOffline = new JLabel(iconOffline);
        
        if (contact.isOnline() == false){ 
            this.add(labelOffline);  
            buttonStart.setEnabled(false);
        }else{
            this.add(labelOnline);
            
        }
        
        
        this.add(labelDescription,LEFT_ALIGNMENT ); 
        this.add(buttonStart,LEFT_ALIGNMENT );
        this.add(buttonDelete);
 
        buttonStart.addActionListener(this.communicationController);
        buttonStart.setActionCommand("buttonStartConversation");
     
        buttonDelete.addActionListener(this.communicationController);
        buttonDelete.setActionCommand("buttonDeleteContactToList");
        buttonDelete.setVisible(false);
        
        
        
    }

    public JLabel getLabelOffline() {
        return labelOffline;
    }

    public void setLabelOffline(JLabel labelOffline) {
        this.labelOffline = labelOffline;
    }

    public JLabel getLabelOnline() {
        return labelOnline;
    }

    public void setLabelOnline(JLabel labelOnline) {
        this.labelOnline = labelOnline;
    }
    
    
    
    public Color getColor() {
        return color;
    }

    public void setColor(Color color) {
        this.color = color;
    }
    
    public JButton getButtonStart() {
        return buttonStart;
    }
    
    public void setButtonStart(JButton buttonStart) {
        this.buttonStart = buttonStart;
    }
    
    public JLabel getLabelDescription() {
        return labelDescription;
    }
    
    public void setLabelDescription(JLabel labelDescription) {
        this.labelDescription = labelDescription;
    }
    
    public JLabel getLabelIpAdress() {
        return labelIpAdress;
    }
    
    public void setLabelIpAdress(JLabel labelIpAdress) {
        this.labelIpAdress = labelIpAdress;
    }
    
    public Contact getContact() {
        return contact;
    }
    
    public void setContact(Contact contact) {
        this.contact = contact;
    }

    public ListContactPanel getListContactPanel() {
        return listContactPanel;
    }

    public void setListContactPanel(ListContactPanel listContactPanel) {
        this.listContactPanel = listContactPanel;
    }

    public JScrollPane getScrollPane() {
        return scrollPane;
    }

    public void setScrollPane(JScrollPane scrollPane) {
        this.scrollPane = scrollPane;
    }
    
    
    
}
